//使用vue-router定义路由
import {createRouter,createWebHistory} from 'vue-router'

//导入组件
import LoginVue from '@/views/Login.vue'
import LayoutVue from '@/views/Layout.vue'

//导入LayoutVue的五个子路由对应的组件
import ArticleCategoryVue from '@/views/article/ArticleCategory.vue'
import ArticleManageVue from '@/views/article/ArticleManage.vue'
import UserAvatarVue from '@/views/user/UserAvatar.vue'
import UserInfoVue from '@/views/user/UserInfo.vue'
import UserResetPasswordVue from '@/views/user/UserResetPassword.vue'
//定义路由关系
const routes=[
    {path:'/login',component:LoginVue},//path是url路径，component是要展示的组件
    {path:'/',component:LayoutVue,redirect:'/article/category',children:[//redirect重定向，当访问/时重定向到/article/category
        //定义子路由
        {path:'/article/category',component:ArticleCategoryVue},
        {path:'/article/mange',component:ArticleManageVue},
        {path:'/user/info',component:UserInfoVue},
        {path:'/user/avatar',component:UserAvatarVue},
        {path:'/user/resetPassword',component:UserResetPasswordVue},
        
    ]},
]
//创建路由器
const router=createRouter({
    history:createWebHistory(),//路由模式两种，另一种时hash
    routes:routes
})
//导出路由
export default router